package com.runa.monitor.platinterface.config;

import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * 资源服务配置
 *
 * @author yuhy 2019-3-13
 */
@EnableResourceServer
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.csrf().disable().authorizeRequests()
                .antMatchers("/actuator/**").permitAll() //监控端点开放
                .antMatchers("/swagger-ui.html").permitAll() //监控端点开放
                .antMatchers("/swagger-resources/**").permitAll() //监控端点开放
                .antMatchers("/webjars/**").permitAll() //监控端点开放
                .antMatchers("/v2/**").permitAll() //监控端点开放
//                .antMatchers("/lintu/**").permitAll() //监控端点开放
                .antMatchers("/comm/**").permitAll() //监控端点开放
                .antMatchers("/websocket").permitAll()
                .anyRequest().hasRole("NORMAL"); //外部接口，需要具有NORMAL角色
    }

}
